import BaseRemote from './BaseRemote';

export default class Remote {
  constructor() {
    this.baseRemote = new BaseRemote();
    this.header = {};
    this.header['Content-Type'] = 'application/json';
    this.header['Accept'] = 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8';
    this.header['Accept-Encoding'] = 'gzip, deflate, sdch';
    this.header['Accept-Language'] = 'zh-CN,zh;q=0.8';
    this.header['Cache-Control'] = 'max-age=0';
    this.header['Connection'] = 'keep-alive';
    this.header['Host'] = 'api.nohttp.net';
  }

  getDataFromRemote(url) {
    return this.baseRemote.getData(url, this.header, null).then((data) => {
      return data;
    }).catch((error) => {
      throw error;
    })
  }

  postDataFromRemote(url, body) {
    return this.baseRemote.postData(url, this.header, body).then((data) => {
      return data;
    }).catch((error) => {
      throw error;
    })
  }
}
